package com.example.design.strategy;

public class MovieTicket {
	private double price;
	private String type;
	
	private Discount discount;
	
	public void setDiscount(Discount discount) {
		this.discount = discount;
	}
	
	public double getPrice() {
		return this.discount.calculate(this.price);
	}

	
	public void setPrice(double price) {
		this.price = price;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	public double calculate() {
		if(this.type.equalsIgnoreCase("student")){
			System.out.println("学生票：");
			return this.price * 0.8;
		}else if(this.type.equalsIgnoreCase("children") && this.price >= 20){
			System.out.println("儿童票：");
			return this.price - 10;
		} else if(this.type.equalsIgnoreCase("vip")) {
			System.out.println("Vip票价：");
			System.out.println(" 增加积分！");
			return this.price * 0.5;
		} else {
			return this.price;
		}
 	}

}
